﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CMS.Infos
{
    public class User:ICloneable,IAssignable
    {
        /// <summary>
        /// 用户名
        /// </summary>
        [JsonProperty(PropertyName ="user_name")]
        public string UserName { get; set; }

        /// <summary>
        /// 权限等级
        /// </summary>
        [JsonProperty(PropertyName = "level")]
        public int Level { get; set; } = 10;

        /// <summary>
        /// 启用状态
        /// </summary>
        [JsonProperty(PropertyName = "status")]
        public bool Status { get; set; } = true;

        public object Assign(object src)
        {
            if (src is User src2)
            {
                UserName = src2.UserName;
                Level = src2.Level;
                Status = src2.Status;
            }else
            {
                throw new ArgumentException();
            }

            return this;
        }

        public object Clone()
        {
            return new User().Assign(this);
        }
    }
}
